#include <stdio.h>

#define N 10

void InputArray(int a[][N], int m, int n);
void ArrayOp(int a[N][N], int m, int n, int mode);
void OutputArray(int a[][N], int m, int n);

int main()
{   	   	
    int m, n, mode;
    int a[N][N];

    printf("Input m,n:\n");//1
    scanf("%d,%d", &m, &n);
    InputArray(a, m, n);//1
    printf("Input operation mode:\n");//1
    scanf("%d", &mode);
    ArrayOp(a, m, n, mode);//1

    return 0;
}   	   	

void InputArray(int a[][N], int m, int n)
{   	   	
    int i, j;
    printf("Input %d*%d array:\n", m, n);
    for (i = 0; i < m; i++)
    {   	   	
        for (j = 0; j < n; j++)
        {   	   	
            scanf("%d", a[i] + j);//1
        }
    }
}   	   	

void ArrayOp(int a[N][N], int m, int n, int mode)
{   	   	
    int i, j;
    int after[N][N];
    int mm, nn;

    switch (mode)
    {   	   	
    case 0:
        for (i = 0; i < m; i++)
            for (j = 0; j < n; j++)
                after[i][j] = a[i][n - j - 1];//1
        mm = m;
        nn = n;
        break;
    case 1:
        for (i = 0; i < m; i++)
            for (j = 0; j < n; j++)
                after[i][j] = a[m - i - 1][j];//1
        mm = m;
        nn = n;
        break;
    case 2:
        for (i = 0; i < m; i++)
            for (j = 0; j < n; j++)
                after[j][i] = a[i][j];//1
        mm = n;
        nn = m;
        break;
    }
    OutputArray(after, mm, nn);//1
}   	   	

void OutputArray(int a[][N], int m, int n)
{   	   	
    int i, j;
    printf("After operation:\n");
    for (i = 0; i < m; i++)
    {   	   	
        for (j = 0; j < n; j++)
            printf("%4d", a[i][j]);//1
        printf("\n");
    }
}   	   	